export const model = {
    id: undefined,
    name: undefined,
    dataKey: undefined,
    content: undefined,
    useSource: undefined,
    useStatus: 0
}
export const rules = {
    name: [
        { required: true, message: '请输入协议名称', trigger: 'blur' },
    ],
    dataKey: [
        { required: true, message: '请输入协议KEY', trigger: 'blur' },
    ],
    content: [
        { required: true, message: '请输入协议内容', trigger: 'blur' },
    ],
    useSource: [
        { required: true, message: '请输入使用渠道', trigger: 'blur' },
    ],
    useStatus: [
        { required: true, message: '请输入状态', trigger: 'blur' },
    ],
}
export const columns = [
    {
        title: '序号',
        dataIndex: 'id',
        width: 70,
        align: 'center',
        customRender: (text, record, index) => {
            return index + 1;
        },
    },
    {
        title: '协议名称',
        dataIndex: 'name',
        key: 'name',
        width: 120,
        align: 'center',
        ellipsis: true,
    },
    {
        title: '协议KEY',
        dataIndex: 'dataKey',
        key: 'dataKey',
        width: 120,
        align: 'center',
        ellipsis: true,
    },
    {
        title: '使用渠道',
        dataIndex: 'useSource',
        key: 'useSource',
        width: 120,
        align: 'center',
        ellipsis: true,
        scopedSlots: { customRender: 'useSource' },
    },
    {
        title: '使用状态',
        dataIndex: 'useStatus',
        key: 'useStatus',
        width: 80,
        align: 'center',
        scopedSlots: { customRender: 'useStatus' },
    },
    {
        title: '更新人',
        dataIndex: 'updateBy',
        key: 'updateBy',
        width: 80,
        align: 'center',
    },
    {
        title: '更新时间',
        dataIndex: 'updateTime',
        key: 'updateTime',
        width: 120,
        align: 'center',
    },
    {
        title: '创建人',
        dataIndex: 'createBy',
        key: 'createBy',
        width: 80,
        align: 'center',
    },
    {
        title: '创建时间',
        dataIndex: 'createTime',
        key: 'createTime',
        width: 120,
        align: 'center',
    },
    {
        title: '操作',
        key: 'action',
        width: 150,
        fixed: 'right',
        scopedSlots: { customRender: 'action' },
    },
];

export const useSource = [
    {
        label: "用户端",
        value: 1,
        color: "blue"
    },
    {
        label: "代理端",
        value: 2,
        color: "green"
    },
    {
        label: "商户端",
        value: 3,
        color: "red"
    }
]
export function getUseSource(data) {
    return useSource.filter(x => x.value === data)[0]
}